package com.yankun.test.person;

public class EnumTestClass {
    public void test1 (EnumTest en) {
        switch (en){
            case Up :
                System.out.println("这个是向上的");break;
            case Down:
                System.out.println("这个是向下的");break;
        }
    }
    public static void main(String[] args) {
        EnumTestClass test = new EnumTestClass();
        test.test1(EnumTest.Up);
        System.out.println(EnumTest.Up.ordinal()); //打印索引
        EnumTest[] arr = EnumTest.values();
        for(int i = arr.length;i>0;i--){
            arr[i-1].show();
        }
        test.test1(EnumTest.Down);
        EnumTest obj = EnumTest.valueOf("Up");
        System.out.println("fafaf"+obj.toString());

        for(int i = arr.length;i>0;i--){
            System.out.println("先后顺序是"+arr[i-1].compareTo(obj)); //比较其实是下标相减
        }
    }
}
